1878C - Vasilije in Cacak - CodeForces Solution


math

Please click on ads to support us..

C++ Code:

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
 #pragma GCC optimize("unroll-loops")
 #include <bits/stdc++.h>
 #include <complex>
 #include <queue>
 #include <set>
 #include <unordered_set>
 #include <list>
 #include <chrono>
 #include <random>
 #include <iostream>
 #include <algorithm>
 #include <cmath>
 #include <string>
 #include <vector>
 #include <map>
 #include <unordered_map>
 #include <stack>
 #include <iomanip>
 #include <fstream>
 #include <bitset>
 #include <numeric>
 using namespace std;
 using std::cout;
 using std::endl;
 using std::string;
 using std::bitset;
 typedef unsigned long long ull;
 typedef long long ll;
 typedef long double ld;
 typedef pair<int,int> p32;
 typedef pair<ll,ll> p64;
 typedef pair<double,double> pdd;
 typedef vector<ll> v64;
 typedef vector<int> v32;
 typedef vector<vector<int> > vv32;
 typedef vector<vector<ll> > vv64;
 typedef vector<vector<p64> > vvp64;
 typedef vector<p64> vp64;
 typedef vector<p32> vp32;
 ll MOD = 1000000007;
 double eps = 1e-12;
 #define forn(i,e) for(ll i = 0; i < e; i++)
 #define forsn(i,s,e) for(ll i = s; i < e; i++)
 #define rforn(i,s) for(ll i = s; i >= 0; i--)
 #define rforsn(i,s,e) for(ll i = s; i >= e; i--)
 #define forr(it,t) for(ll it=1;it<=t;it++)
 #define dbg(x) cout<<#x<<" = "<<x<<ln
 #define mp make_pair
 #define pb push_back
 #define fi first
 #define se second
 #define INF 2e18
 #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 #define all(x) (x).begin(), (x).end()
 #define al(arr,n)arr,arr+n
 #define sz(x) ((ll)(x).size())


void solve(){

}
int main()
{
fast_cin();
ll t;
cin >> t;
while(t--){
long long n,k,s;
cin>>n>>k>>s;
long long sm=0,sm1=0,sm2=0;
sm = (n*(n+1))/2;
sm1 = (k*(k+1))/2;
int x=n;
for(int i=0; i<k; i++){
    sm2 += x;
    x--;
}
//if(s%2!=0 && k%2==0) cout<<"NO"<<endl;
if(sm<s || sm1>s) cout<<"NO"<<endl;
else if(sm2<s) cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}


Comments

Submit
0 Comments
More Questions

1619B - Squares and Cubes
1619A - Square String
1629B - GCD Arrays
1629A - Download More RAM
1629C - Meximum Array
1629D - Peculiar Movie Preferences
1629E - Grid Xor
1629F1 - Game on Sum (Easy Version)
2148. Count Elements With Strictly Smaller and Greater Elements
2149. Rearrange Array Elements by Sign
2150. Find All Lonely Numbers in the Array
2151. Maximum Good People Based on Statements
2144. Minimum Cost of Buying Candies With Discount
Non empty subsets
1630A - And Matching
1630B - Range and Partition
1630C - Paint the Middle
1630D - Flipping Range
1328A - Divisibility Problem
339A - Helpful Maths
4A - Watermelon
476A - Dreamoon and Stairs
1409A - Yet Another Two Integers Problem
977A - Wrong Subtraction
263A - Beautiful Matrix
180C - Letter
151A - Soft Drinking
1352A - Sum of Round Numbers
281A - Word Capitalization
1646A - Square Counting